import { NextResponse } from "next/server"

/**
 * 获取歌手列表
 *
 * @route GET /api/artists
 * @param {number} page - 页码，默认为1
 * @param {number} limit - 每页数量，默认为20
 * @param {string} genre - 音乐类型（可选）
 *
 * @returns {Object} 返回歌手列表和分页信息
 *
 * 请求示例:
 * GET /api/artists?page=1&limit=20&genre=流行
 *
 * 返回示例:
 * {
 *   "success": true,
 *   "data": [
 *     {
 *       "id": "artist001",
 *       "name": "周杰伦",
 *       "avatar": "https://example.com/avatar/jaychou.jpg",
 *       "genre": "流行",
 *       "popularity": 98
 *     },
 *     // ... 更多歌手
 *   ],
 *   "pagination": {
 *     "currentPage": 1,
 *     "totalPages": 50,
 *     "totalItems": 1000
 *   }
 * }
 */
export async function GET(request: Request) {
  const { searchParams } = new URL(request.url)
  const page = Number.parseInt(searchParams.get("page") || "1")
  const limit = Number.parseInt(searchParams.get("limit") || "20")
  const genre = searchParams.get("genre")

  // 实现获取歌手列表逻辑
  return NextResponse.json({
    success: true,
    data: [
      {
        id: "artist001",
        name: "周杰伦",
        avatar: "https://example.com/avatar/jaychou.jpg",
        genre: "流行",
        popularity: 98,
      },
      // ... 更多歌手
    ],
    pagination: {
      currentPage: page,
      totalPages: 50,
      totalItems: 1000,
    },
  })
}

/**
 * 获取歌手详情
 *
 * @route GET /api/artists/[id]
 * @param {string} id - 歌手ID
 *
 * @returns {Object} 返回歌手详细信息
 *
 * 请求示例:
 * GET /api/artists/artist001
 *
 * 返回示例:
 * {
 *   "success": true,
 *   "data": {
 *     "id": "artist001",
 *     "name": "周杰伦",
 *     "avatar": "https://example.com/avatar/jaychou.jpg",
 *     "genre": "流行",
 *     "description": "周杰伦是一位著名的华语流行音乐歌手、音乐人、演员...",
 *     "popularity": 98,
 *     "albums": [
 *       {
 *         "id": "album001",
 *         "name": "Jay",
 *         "releaseDate": "2000-11-07"
 *       },
 *       // ... 更多专辑
 *     ],
 *     "topSongs": [
 *       {
 *         "id": "song001",
 *         "name": "晴天",
 *         "playCount": 1000000
 *       },
 *       // ... 更多热门歌曲
 *     ]
 *   }
 * }
 */
export async function GET(request: Request, { params }: { params: { id: string } }) {
  const id = params.id

  // 实现获取歌手详情逻辑
  return NextResponse.json({
    success: true,
    data: {
      id: "artist001",
      name: "周杰伦",
      avatar: "https://example.com/avatar/jaychou.jpg",
      genre: "流行",
      description: "周杰伦是一位著名的华语流行音乐歌手、音乐人、演员...",
      popularity: 98,
      albums: [
        {
          id: "album001",
          name: "Jay",
          releaseDate: "2000-11-07",
        },
        // ... 更多专辑
      ],
      topSongs: [
        {
          id: "song001",
          name: "晴天",
          playCount: 1000000,
        },
        // ... 更多热门歌曲
      ],
    },
  })
}

